<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/pages/setting.css" />
	</head>

	<body>
		<div id="app" class="content">
			<div class="user-list">
				<div class="item" @click="aboutClick">
					<span class="item-desc">
						关于我们
					</span>
					<span class="mui-icon mui-icon-arrowright"></span>
				</div>
				<div class="item" @click="shareClick">
					<span class="item-desc">
						分享推荐
					</span>
					<span class="mui-icon mui-icon-arrowright"></span>
				</div>
				<div class="item" @click="feedbackClick">
					<span class="item-desc">
						意见反馈
					</span>
					<span class="mui-icon mui-icon-arrowright"></span>
				</div>
				<div class="item m-b-30" @click="onkefu">
					<span class="item-desc">
						客服电话
					</span>
					<span class="mui-icon mui-icon-arrowright"></span>
				</div>
			</div>
			<div class="user-list" >
				<div class="item" @click="exitClick">
					<div style="flex: 1; text-align: center;">退出</div>
				</div>
			</div>
		</div>
	</body>
	<script src="../../js/Width.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/vue.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/app.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/Util.js"></script>
	<script src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
	<script>
		mui.init()
		mui.plusReady(function() {
			if (!mui.os.android) {
				FastClick.attach(document.body);
			}
			plus.share.getServices(function(shares) {
				app.shares = shares
			}, function() {
				console.log("获取分享服务列表失败");
			});
		})

		var app = new Vue({
			el: '#app',
			data: {
				shares: []
			},
			methods: {
				shareClick: function() { // 分享,
					var shares = this.shares
					var that = this
					var bts = [{
							title: "发送给微信好友",
							id: "weixin",
							ex: "WXSceneSession"
						}, {
							title: "分享到微信朋友圈",
							id: "weixin",
							ex: "WXSceneTimeline"
						}, {
							title: "分享到QQ",
							id: "qq"
						}];
					plus.nativeUI.actionSheet({
						cancel: "取消",
						buttons: bts
					}, function(e) {
						if(e.index <= 0){
							return
						}
						var i = e.index -1;
						var share;
						shares.forEach(function(item,index){
							if(bts[i].id==item.id){
								share = item
							}
						})
						that.shareMessage(share,bts[i].ex)
					});
				},
				onkefu:function(){
					mui.openWindow({
						url: '/pages/home/callCenter.html',
						id: 'callCenter', 
						waiting: {
							autoShow: false
						}
					})
				},
				shareMessage: function(share, ex) {
					var msg = {
						href: "https://m.wandoujia.com/apps/io.dcloud.H51CF3EB4",
						title: "大管家物业",
						content: "物业管理APP是一个方便物业 发布制定每位员工的例行任务，待办任务。",
						thumbs: ["https://android-artworks.25pp.com/fs08/2018/09/14/6/110_4c1bc44adfb29be20188b2244b361b80_con_130x130.png"],
						extra: {
							scene: ex
						}
					};
					share.send(msg, function() {
						mui.toast("分享到\"" + share.description + "\"成功！ ");
					}, function(e) {
						// mui.toast("分享到\"" + share.description + "\"失败: " + e.code + " - " + e.message);
					});
				},
				aboutClick: function () { //关于我们
					mui.openWindow({
						url: 'about.html',
						id: 'about',
						styles: { // 窗口参数 参考5+规范中的WebviewStyle,也就是说WebviewStyle下的参数都可以在此设置
							titleNView: { // 窗口的标题栏控件
								titleText: "关于我们", // 标题栏文字,当不设置此属性时，默认加载当前页面的标题，并自动更新页面的标题         // 字体颜色,颜色值格式为"#RRGGBB",默认值为"#000000"
								titleSize: "17px", // 字体大小,默认17px
								backgroundColor: "#ffffff", // 控件背景颜色,颜色值格式为"#RRGGBB",默认值为"#F7F7F7"
								autoBackButton: true
							}
						},
						waiting: {
							autoShow: false
						}
					})
				},
				feedbackClick: function () { // 意见反馈
					mui.openWindow({
						url: 'feedback.html',
						id: 'feedback',
						styles: { // 窗口参数 参考5+规范中的WebviewStyle,也就是说WebviewStyle下的参数都可以在此设置
							titleNView: { // 窗口的标题栏控件
								titleText: "意见反馈", // 标题栏文字,当不设置此属性时，默认加载当前页面的标题，并自动更新页面的标题         // 字体颜色,颜色值格式为"#RRGGBB",默认值为"#000000"
								titleSize: "17px", // 字体大小,默认17px
								backgroundColor: "#ffffff", // 控件背景颜色,颜色值格式为"#RRGGBB",默认值为"#F7F7F7"
								autoBackButton: true
							}
						},
						waiting: {
							autoShow: false
						}
					})
				},
				exitClick: function () {
					plus.nativeUI.confirm("确定关闭APP应用？", function (e) {
						if (e.index == 0) {
							Util.removeItem('$settings')
						    if(mui.os.android){
								plus.runtime.quit();
							} else {
								var curr = plus.webview.currentWebview();
								var wvs = plus.webview.all();
								for (var i = 0, len = wvs.length; i < len; i++) {
									//关闭除setting页面外的其他页面
									if (wvs[i].getURL() == curr.getURL())
										continue;
									plus.webview.close(wvs[i]);
								}
								//打开login页面后再关闭setting页面
								plus.webview.open('../../login.html');
								curr.close();
							}
							
						}
					})
				}
			}
		})
	</script>

</html>
